<?php
include_once 'DBCon.php';
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Discountrate
 *
 * @author user
 */
class Discountrate {
    private $con;
    private $discountrate;
    private $discountId;
    private $selectrate = 'SELECT discountId, rate 
        FROM discountrate 
        WHERE CURDATE() BETWEEN startDate AND endDate 
        AND discountId != 1 AND status != "DEL"
        LIMIT 1;';
    
    function __construct() {
        $this->con = DBCon::connectDB();
    }
    
    public function getDiscountrate(){
        $pstmtselect = $this->con->prepare($this->selectrate);
        $pstmtselect->bind_result($this->discountId,$this->discountrate);
        $pstmtselect->execute();
        if($pstmtselect->fetch()){
            $discount = array(
                'did' => $this->discountId,
                'rate' => $this->discountrate
            );
            return $discount;
        }else{
            return null;
        }
    }

}

?>
